<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"
	trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/apps_res/plugin/tinymce/app.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/apps_res/plugin/tinymce/iconfont.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/apps_res/plugin/tinymce/jquery-3.2.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/apps_res/plugin/tinymce/tinymce.min.js"
	referrerpolicy="origin"></script>
</head>
<style type="text/css">
.top-print {
	height: 50px;
	background-color: rgb(0, 0, 0);
	opacity: 0.1;
	position: absolute;
	width: 100%;
	z-index: 50;
	margin-bottom: 20px;
}

.btn-print {
	display: inline-block;
	padding: 6px 12px;
	margin-bottom: 0;
	font-size: 14px;
	font-weight: normal;
	line-height: 1.42857143;
	text-align: center;
	white-space: nowrap;
	vertical-align: middle;
	-ms-touch-action: manipulation;
	touch-action: manipulation;
	cursor: pointer;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	background-image: none;
	border: 1px solid transparent;
	border-radius: 4px color: #fff;
	background-color: #337ab7;
	border-color: #2e6da4;
	color: #fff;
	border-radius: 3px;
	position: relative;
	top: 15px;
	left: 47px;
	z-index: 1000;
}

.btn-print:hover {
	cursor: pointer
}

div{
    margin: 0 auto;
}
</style>
<body>
	<div class="col-xs-12 top-print"></div>
	<input type="button" class="btn-print" value="打印" />
</body>
<script type="text/javascript">
	var table = window.opener.getTest();
	var content;
	$('body').append(table);
	removeNode();
	var  str = '{"a":"a1","b":"b1"}';

	var obj1 = eval('('+str+')'); //使用eval函数

	var obj2 = jQuery.parseJSON(str); //jq对象方法，由json字符串转换为json对象
	
	getCaseContext();
	$('.btn-print').click(function() {
		$('.col-xs-12').hide();
		$('.btn-print').hide();
		window.print();
		$('.col-xs-12').show();
		$('.btn-print').show();
	})
	/* 删除节点 */
	function removeNode() {
		var as = $('pre');
		for (var i = 0; i < as.length; i++) {
			var _t = as[i];
			if (_t.innerText == '详细内容 (상세내용)') {
				var _tr = _t.parentNode.parentNode.parentNode.parentNode;
				content = _tr;
				for (var tr = 0; tr < _tr.children.length;) {
					if (isIE() || isIE11())
						_tr.children[tr].removeNode(true);
					else
						_tr.children[tr].remove();
				}
			}
		}
	}

	/* 获取url参数的值 */
	function getQueryString(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = window.location.search.substr(1).match(reg);
		if (r != null)
			return unescape(r[2]);
		return null;
	}

	function getCaseContext() {
		var id = getQueryString("id");
		console.log("id:" + id);
		$
				.ajax({
					url : '${pageContext.request.contextPath}/showUeditor.do?method=getCaseContext&id='+id,
					type : "get",
					success : function(status) {
						var str = status.substr(16,(status.length));
						var text =str.substr(0,str.lastIndexOf('}'));
						var context = encodeURIComponent(text.substr(0,(text.lastIndexOf('"'))));
						setContent(decodeURIComponent(context));
					},error: function(xhr, ajaxOptions, thrownError) {
						alert('请求错误！');
					}
				});
	}
	/* 写入起案正文 */
	function setContent(text) {
		if (content != undefined) {
			content.style.cssText = 'height:auto';
			content.innerHTML = '<td colspan="16" rowspan="1" style=" '
					+ 'padding: 1px 2px; border-bottom: 1px solid rgb(102, 102, 102); '
					+ 'border-left: 1px solid rgb(102, 102, 102); border-right:'
					+ '1px solid rgb(102, 102, 102); width: 900px;">' + text
					+ '</td>';
		}
	}
	function isIE() {
		if (!!window.ActiveXObject || "ActiveXObject" in window) {
			return true;
		} else {
			return false;
		}
	}

	function isIE11() {
		if ((/Trident\/7\./).test(navigator.userAgent)) {
			return true;
		} else {
			return false;
		}
	}
</script>
</html>